package ms.maplestory.boot.client.character.quest.requirement;

import lombok.Getter;
import lombok.Setter;
import ms.maplestory.boot.client.character.Char;
import ms.maplestory.boot.loaders.DatSerializable;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

@Getter
public class QuestStartJobRequirement implements QuestStartRequirement {

    private Set<Integer> jobReq;

    public QuestStartJobRequirement() {
        this.jobReq = new HashSet<>();
    }

    public void addJobReq(int job) {
        jobReq.add(job);
    }

    @Override
    public boolean hasRequirements(Char chr) {
        return false;
    }

    @Override
    public void write(DataOutputStream dos) throws IOException {
        dos.writeShort(jobReq.size());
        for (int s : jobReq) {
            dos.writeInt(s);
        }
    }

    @Override
    public DatSerializable load(DataInputStream dis) throws IOException {
        QuestStartJobRequirement questStartJobRequirement = new QuestStartJobRequirement();
        short size = dis.readShort();
        for (int i = 0; i < size; i++) {
            questStartJobRequirement.addJobReq(dis.readInt());
        }
        return questStartJobRequirement;
    }
}
